@echo off
chcp 65001 >nul

echo =========================================
echo XPath Locator - Quick Start
echo =========================================

REM Start backend directly
echo [1/2] Starting Backend Service...
start "XPath Backend" cmd /k "cd /d %~dp0backend && conda activate fetch && python -m uvicorn app.main:app --reload --host 127.0.0.1 --port 8000"

REM Wait a moment
timeout /t 2 /nobreak >nul

REM Start frontend directly  
echo [2/2] Starting Frontend Service...
start "XPath Frontend" cmd /k "cd /d %~dp0frontend && npm run dev"

echo.
echo =========================================
echo Services are starting in separate windows:
echo.
echo Backend:  http://127.0.0.1:8000
echo Frontend: http://localhost:5173
echo API Docs: http://127.0.0.1:8000/docs
echo.
echo Wait a few seconds for services to initialize,
echo then open http://localhost:5173 in your browser
echo =========================================

REM Auto-open browser after delay
echo Waiting 8 seconds before opening browser...
timeout /t 8 /nobreak >nul
start http://localhost:5173

pause